Game xếp hình 2048

13.196 lượt xem;
1 using UnityEngine;
2 using
System.Collections;
3
4 public
class MenuScript : MonoBehaviour {
5
6     
private GameControllerScript gameScript;
7     
private GUISkin currentGUISkin;
8     
private Vector2 scrollPosition;
9     
// Use this for initialization
10     
void Start () {
11         
this.gameScript = this.gameObject.GetComponent ("GameControllerScript") as GameControllerScript;
12         
this.currentGUISkin = gameScript.currentGUISkin;
13
14     }
15     
16     
// Update is called once per frame
17     
void Update () {
18     
19     }
20
21     
void OnGUI() {
22         
if (this.gameScript.gameView == "menu") {
23             
this.gameScript.mainCamera.transform.eulerAngles = new Vector3 (180, 23, 0);
24             
this.gameScript.gameLight.intensity = 0;
25
26             
//set the sizes appropriately
27             GUI.skin =
this.gameScript.currentGUISkin;
28             
29             GUIStyle playButtonStyle =
new GUIStyle(currentGUISkin.GetStyle("Button"));
30             playButtonStyle.fontSize = Mathf.CeilToInt(Screen.height *
0.10F);
31             playButtonStyle.fontStyle = FontStyle.Italic;
32
33             
34             GUIStyle menuButtonStyle =
new GUIStyle(currentGUISkin.GetStyle("Button"));
35             menuButtonStyle.fontSize = Mathf.CeilToInt(Screen.height *
0.06F);
36
37             
38             GUIStyle titleLabelStyle =
new GUIStyle(currentGUISkin.GetStyle("TitleLabel"));
39             titleLabelStyle.fontSize = Mathf.CeilToInt(Screen.height *
0.13F);
40
41             GUI.Label (
new Rect (0, 0, Screen.width, Screen.height * 0.06F), "2048 - 3D", titleLabelStyle);
42
43             
44             GUI.Label (
new Rect (0, Screen.height * 0.15F, Screen.width, Screen.height * 0.06F), "");
45
46
47             
if (GUI.Button(new Rect(Screen.width * 0.20f, Screen.height * 0.25f, Screen.width * 0.60F, Screen.height * 0.10F),"Options", menuButtonStyle)) {
48                 
this.gameScript.gameView = "options";
49             }
50             
if (GUI.Button(new Rect(Screen.width * 0.20f, Screen.height * 0.40f, Screen.width * 0.60F, Screen.height * 0.10F),"Instructions", menuButtonStyle)) {
51                 
this.gameScript.gameView = "instructions";
52             }
53             
if (GUI.Button(new Rect(Screen.width * 0.20f, Screen.height * 0.55F, Screen.width * 0.60F, Screen.height * 0.10F),"Exit", menuButtonStyle)) {
54                 Application.Quit();
55             }
56
57             
if (GUI.Button(new Rect(Screen.width * .20f, Screen.height * 0.70F, Screen.width * 0.60F, Screen.height * 0.15F),"Play!",playButtonStyle)) {
58                 
this.gameScript.gameView = "game";
59             }
60
61             GUI.Label (
new Rect (0, Screen.height * 0.94F, Screen.width, Screen.height * 0.06F), " 2018 - Brought To You By code-projects.org");
62
63         }
64     }
65 }


Use this for initialization

Update is called once per frame

set the sizes appropriately



Gõ tìm kiếm nhanh...